var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var util = require('util');
var signServletAgent = require('./servers/getSignServletAgent.js');
var vCodeAgent = require('./servers/verficationCodeAgent.js');
var getNumServletAgent = require('./servers/getNumServletAgent.js');
var youtouAgent = require('./servers/youtuServletAgent.js');
var hengFengAgent = require('./servers/hengFengAgent.js');
var kexinBarbrecordAgent = require('./servers/kexinbadrecordAgent.js');
var kexinBrokenAgent = require('./servers/kexinBrokenAgent.js');

// 创建 application/x-www-form-urlencoded 编码解析
var urlencodedParser = bodyParser.urlencoded({
    extended: false
});

app.get('/', function(req, res) {
    res.send('Hello World');
});

app.get('/dist/faceDetect/faceDetect.html', function(req, res) {
    res.sendFile(__dirname + "/dist/faceDetect/faceDetect.html");
});
app.get('/dist/faceDetect/loding.html', function(req, res) {
    res.sendFile(__dirname + "/dist/faceDetect/loding.html");
});
app.get('/dist/faceDetect/contract.html', function(req, res) {
    res.sendFile(__dirname + "/dist/faceDetect/contract.html");
});
app.get('/dist/faceDetect/credit.html', function(req, res) {
    res.sendFile(__dirname + "/dist/faceDetect/credit.html");
});
app.get('/dist/faceDetect/taskList.html', function(req, res) {
    res.sendFile(__dirname + "/dist/faceDetect/taskList.html");
});
app.get('/dist/faceDetect/developing.html', function(req, res) {
    res.sendFile(__dirname + "/dist/faceDetect/developing.html");
});


app.get('/dist/js/libs/jquery-1.11.1.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/libs/jquery-1.11.1.min.js");
});
app.get('/dist/js/faceDetect/urlValue.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/faceDetect/urlValue.js");
});
app.get('/dist/js/libs/jquery.mobile-1.4.5.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/libs/jquery.mobile-1.4.5.min.js");
});
app.get('/dist/js/faceDetect/common.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/faceDetect/common.js");
});
app.get('/dist/js/faceDetect/faceIndex.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/faceDetect/faceIndex.min.js");
});
app.get('/dist/js/faceDetect/fail.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/faceDetect/fail.min.js");
});
app.get('/dist/js/libs/iscroll.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/libs/iscroll.js");
});
app.get('/dist/js/faceDetect/contract.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/faceDetect/contract.js");
});
app.get('/dist/js/faceDetect/credit.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/faceDetect/credit.min.js");
});
app.get('/dist/js/libs/radialIndicator.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/libs/radialIndicator.js");
});
app.get('/dist/js/faceDetect/taskList.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/faceDetect/taskList.min.js");
});
app.get('/dist/js/faceDetect/developing.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/faceDetect/developing.min.js");
});

 

app.get('/dist/css/faceDetect/faceMain.css', function(req, res) {
    res.sendFile(__dirname + "/dist/css/faceDetect/faceMain.css");
});
app.get('/dist/css/test/fixedLayout.css', function(req, res) {
    res.sendFile(__dirname + "/dist/css/test/fixedLayout.css");
});
app.get('/dist/css/faceDetect/contract.css', function(req, res) {
    res.sendFile(__dirname + "/dist/css/faceDetect/contract.css");
});


app.get('/dist/images/faceDetect/saomiao.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/saomiao.png");
});
app.get('/dist/images/faceDetect/lansebeijing_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/lansebeijing_icon.png");
});
app.get('/dist/images/faceDetect/demo.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/demo.png");
});
app.get('/dist/images/faceDetect/demo2_0.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/demo2_0.png");
});
app.get('/dist/images/faceDetect/demo3.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/demo3.png");
});
app.get('/dist/images/faceDetect/demo2_1.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/demo2_1.png");
});
app.get('/dist/images/faceDetect/demo2_2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/demo2_2.png");
});
app.get('/dist/images/faceDetect/naixindengdai_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/naixindengdai_icon.png");
});
app.get('/dist/images/faceDetect/fristBackground.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/fristBackground.png");
});
app.get('/dist/images/faceDetect/blue@2x.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/blue@2x.png");
});
app.get('/dist/images/faceDetect/tmup.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/tmup.png");
});
app.get('/dist/images/faceDetect/fanhui.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/fanhui.png");
});
app.get('/dist/images/faceDetect/dingwei_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/dingwei_icon.png");
});
app.get('/dist/images/faceDetect/dingwei_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/dingwei_icon.png");
});
app.get('/dist/images/fanhui.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/fanhui.png");
});
app.get('/dist/images/faceDetect/touxtest.jpg', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/touxtest.jpg");
});
app.get('/dist/images/ajax-loader.gif', function(req, res) {
    res.sendFile(__dirname + "/dist/images/ajax-loader.gif");
});
app.get('/dist/images/faceDetect/lansebeijing_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/lansebeijing_icon2.png");
});
app.get('/dist/images/faceDetect/tongguojianyandejiangzhang_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/tongguojianyandejiangzhang_icon.png");
});
app.get('/dist/images/faceDetect/meijiaoyan_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/meijiaoyan_icon.png");
});
app.get('/dist/images/faceDetect/xuelirenzheng_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/xuelirenzheng_icon2.png");
});
app.get('/dist/images/faceDetect/shigongzhong_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/shigongzhong_icon.png");
});
app.get('/dist/images/faceDetect/shebao_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/shebao_icon2.png");
});
app.get('/dist/images/faceDetect/yinhangka_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/yinhangka_icon2.png");
});
app.get('/dist/images/faceDetect/zhengxin_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/zhengxin_icon2.png");
});
app.get('/dist/images/faceDetect/shejiao_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/shejiao_icon2.png");
});
app.get('/dist/images/faceDetect/yunyingshang_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/yunyingshang_icon2.png");
});
app.get('/dist/images/faceDetect/shejiao_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/shejiao_icon2.png");
});
app.get('/dist/images/faceDetect/xinyongka_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/gongzuodanwei_icon2.png");
});
app.get('/dist/images/faceDetect/gongzuodanwei_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/gongzuodanwei_icon2.png");
});
app.get('/dist/images/faceDetect/tongxunlu_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/tongxunlu_icon2.png");
});
app.get('/dist/images/faceDetect/ajax-loader.gif', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/ajax-loader.gif");
});
app.get('/dist/images/faceDetect/shenqingchenggong_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/images/faceDetect/shenqingchenggong_icon.png");
});


 


app.post('/liveDec/GetSignServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = signServletAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});

app.post('/liveDec/SMSSendServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = vCodeAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});
app.post('/liveDec/GetCheckNumServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = getNumServletAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});
app.post('/liveDec/YouTuDetectServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = youtouAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});
app.post('/liveDec/KexinBrokenServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = kexinBrokenAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});
app.post('/liveDec/KexinBadrecordServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = kexinBarbrecordAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});
app.post('/liveDec/HengFengServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = hengFengAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});



var server = app.listen(9082, function() {

    var host = server.address().address;
    var port = server.address().port;

    console.log("应用实例，访问地址为 http://%s:%s", host, port)

});